##############################################################
#Table B10: Hurricane Proximity and Democrat Vote Share: Alternative Specifications
##############################################################

library(wfe)

df <- read.dta13("./input/prec-altspec-hur.dta")

results_mat <- matrix(nrow = 4, ncol = 2,  dimnames = list(c("estimate", "se", "obs", "n_unique"), 
                                                           c("senate", "house")))

results <- wfe(formula = demosenshare_total ~ treatment308080150, data = df, treat = "treatment308080150", 
               unit.index = "group", qoi="att", time.index = "year", estimator = "did")
summary(results)
results_mat[,1] <- c(results$coefficients[1], sqrt(results$vcov), results$df, nrow(results$units)) 


results <- wfe(formula = demohouseshare_total ~ treatment308080150, data = df, treat = "treatment308080150", 
               unit.index = "group", qoi="att", time.index = "year", estimator = "did")
summary(results)
results_mat[,2] <- c(results$coefficients[1], sqrt(results$vcov), results$df, nrow(results$units)) 

xtable(as.data.frame(results_mat), digits=3)

tabb10b <- xtable(as.data.frame(results_mat), digits=3, print.results="FALSE")
print(tabb10b,file="./figures/tabb10b.tex")

